// import _ from 'lodash';
// import './style.css'
// import Icon from './wx.png';
// import Data from './data.xml';
import printMe from './print.js';
import { cube } from './math.js';

// function component(){
//      var element = document.createElement('div');
//      var element2 = document.createElement('pre');
    //'_'就是一个对象全局变量，挂载所有Lodash的方法
    // element.innerHTML = _.join(['Hello','webpack'], ' ');
    //element.classList属性用于返回一个元素的className集合，并且该属性拥有add，remove，toggle，contains方法
    // element.classList.add('hello');

    //将图像添加到我们现有的div
    // var myIcon = new Image();
    // myIcon.src = Icon;
    // console.log(Data);
//     element2.innerHTML =
//         '5 cubed is equal to' + cube(5);

//     var btn = document.createElement('button');
//     btn.innerHTML = 'Click me and check the console!'
//     btn.onclick = printMe;

//     element.appendChild(btn);

//     return element2;
// }
// document.body.appendChild(component());


async function getComponent(){
    // return import(/*webpackChunkName:"lodash"*/"lodash").then(_=>{
    //     var element = document.createElement('div');
    //     element.innerHTML = _.join(['Hello','webpack'],' ');

    //     return element;
    // }).catch(error => 'An error occured while loading the component');
    var element = document.createElement('div');
    const _ = await import(/* webpackChunkName: "lodash" */'lodash');
    element.innerHTML = _.join(['Hello','webpack'], ' ');
    return element;
}

getComponent().then(component => {
    document.body.appendChild(component);
})

if(module.hot){
    module.hot.accept('./print.js',function(){
        console.log('Accepting the updated printMe module!');
        printMe();
    })
}